//
//  CustomHeaderView.m
//  10-homeWork-YICheCell
//
//  Created by 王道林 on 16/7/27.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "CustomHeaderView.h"
#import "AlbumView.h"

@implementation CustomHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame PicArray:(NSArray<UIImage *> *)picArray
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViewFrame:frame PicArray:picArray];
    }
    return self;
}

- (void)createSubViewFrame:(CGRect)frame PicArray:(NSArray<UIImage *> *)picArray
{
    AlbumView *albumView = [[AlbumView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 180) PicArray:picArray];
    [self addSubview:albumView];
    NSArray *arrOfTitle = @[@"贷款买车", @"直销车型", @"底价买车", @"二手车"];
    NSArray *arrOfPic = @[@"1", @"2", @"3", @"4"];
    for (int i = 0; i < 4; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.frame = CGRectMake(frame.size.width / 4 * i + i, 180, frame.size.width / 4, 80);
        [button setBackgroundImage:[UIImage imageNamed:arrOfPic[i]] forState:UIControlStateNormal];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width / 4 * i + i, 260, frame.size.width / 4, 20)];
        label.text = arrOfTitle[i];
        label.backgroundColor = [UIColor whiteColor];
        [self addSubview:label];
        label.textAlignment = 1;
        [self addSubview:button];
    }
}


@end
